﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="mp3toyoutube1.aspx.cs" Inherits="Secure_mp3toyoutube1" %>

<%@ Register Src="AdminSubTitle.ascx" TagName="AdminSubTitle" TagPrefix="uc2" %>

<%@ Register Src="../EmlynOReganTitle.ascx" TagName="EmlynOReganTitle" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Emlyn O'Regan Home - MP3 to Youtube proto #1</title>
    <link rel="StyleSheet" href="../EmlynORegan.css" type="text/css" />
    <link rel="StyleSheet" href="../EmlynOReganMain.css" type="text/css" />
    <script type="text/javascript">
    
    var t;
    var c = 0;
    function DoProgress()
    {
        var x=document.getElementById("ProgressLabel");
        if (c < 20)
        {
            x.innerHTML = c;
            c++;
            
            t=setTimeout("DoProgress()",1000);
        }
        else
        {
            x.innerHTML = "Done";
        }
    }

    var filedone;
    var filemessage;
    
    function SetCheckForFileLabel(message)
    {
        var x=document.getElementById("CheckForFileLabel");
        x.innerHTML = message;
    }

    function CheckForFile()
    {
//var txtFile = new XMLHttpRequest();
//txtFile.open("GET", "http://my.remote.url/myremotefile.txt", true);
//txtFile.onreadystatechange = function() {
//  if (txtFile.readyState === 4) {  // Makes sure the document is ready to parse.
//    if (txtFile.status === 200) {  // Makes sure it's found the file.
//      allText = txtFile.responseText;
//      lines = txtFile.responseText.split("\n"); // Will separate each line into an array
//    }
//  }
//}
//txtFile.send(null); 
        SetCheckForFileLabel("started2");

        filedone = false;
        filemessage = "Waiting for file";

        var txtFile = new XMLHttpRequest();
        
        //txtFile.open("GET", "http://localhost:3683/Emlyn.Website.EmlynORegan/Secure/mp3toyoutube1.aspx", true);
        txtFile.open("GET", "file://C:/Documents%20and%20Settings/emlyn/Desktop/Photo0003.jpg", true);
        txtFile.onreadystatechange = function() {
          filedone = true;
          if (txtFile.readyState === 4) {  // Makes sure the document is ready to parse.
            if (txtFile.status === 200) {  // Makes sure it's found the file.
              allText = txtFile.responseText;
              lines = txtFile.responseText.split("\n"); // Will separate each line into an array
              filemessage = "success";
            }
            else
                filemessage = "txtFile.status == " + txtFile.status;
          }
          else
            filemessage = "readyState == " + txtFile.readyState;
        }
        txtFile.send(null);
    
        SetCheckForFileLabel(filemessage);
        
        MonitorFile();
    }
    
    function MonitorFile()
    {
        if (!filedone)
        {
            filemessage += ".";
            SetCheckForFileLabel(filemessage);
            setTimeout("MonitorFile()",1000);
        }
        else
        {
            SetCheckForFileLabel(filemessage);
        }
    }
    
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc1:EmlynOReganTitle ID="EmlynOReganTitle1" runat="server"  />
        <br />
        <uc2:AdminSubTitle ID="AdminSubTitle1" runat="server" AuthLevel="1" />
        <br />
        <p />
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            &nbsp;&nbsp;
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
            &nbsp;&nbsp;
        </ContentTemplate>
    </asp:UpdatePanel>
            <p id="ProgressLabel" onclick="DoProgress()">Start counting</p>
            
            <p id="CheckForFileLabel" onclick="CheckForFile()">Check for file</p>
    </form>
</body>
</html>
